import React, { Component } from "react";
//1. 导入 prop-types
import PropTypes from 'prop-types';
export default class PropTypeCom extends Component {
  // 2. 声明静态属性
  static propTypes = {
    name: PropTypes.string,
    age: PropTypes.number
  }

  //属性的默认值
  static defaultProps = {
    age: 18
  }


  render() {
    //解构数据
    let {name, age, gender} = this.props;
    return (
      <div>
        <ul>
          <li>姓名:{name}</li>
          <li>年龄:{age}</li>
          <li>性别:{gender}</li>
        </ul>
        <hr style={{margin: '20px 0'}} />
      </div>
    );
  }
}
